<?php

	include "../conf/config.php";
	$result = mysql_connect($host,$granted_user,$granted_mdp)or die("impossible de se connecter"); 
	$result = mysql_select_db($db_name)or die("ne peut selectioner DB");

	if (!$result) {
 		$message  = 'Requête invalide : ' . mysql_error() . "\n";
		$message .= 'Requête complète : ' . $query;
		die($message);
		echo $message;
	}

	if (isset($_POST['valider'])) {

		if (isset($_POST['valid']) && is_array($_POST['valid']))
		{

			$valid = $_POST['valid'] ;
			$date = date("Y-m-d");


			foreach ($valid as $key => $value) 
			{
				$sql = "UPDATE evo SET date_modif = '".$date."', skill_validate = progression WHERE id_evo='".$key."';";
				$ok = mysql_query($sql); 
			}

			$sql = "SELECT skill_validate, progression, id_evo FROM evo WHERE skill_validate != progression";
			$ok = mysql_query($sql);

			while ($row = mysql_fetch_array($ok)) {
				$sql = "UPDATE evo SET progression = skill_validate WHERE id_evo='".$row['id_evo']."';";
				$ok = mysql_query($sql); 
			}

		}

	}


	$_SESSION['user']['message'] = "Modifications effectuées.";
	$location = 'index.php';
	header('Location: ' . $location);

?>